<template>
  <div class="tab-container waybill-tab-container tab-fixed">
    <el-tabs v-model="activeName">
      <el-tab-pane
        v-for="item in tabMapOptions"
        :key="item.key"
        :label="$t(`waybill.${item.label}`)"
        :name="item.key"
        class="padding"
      >
        <keep-alive>
          <tab-pane
            v-if="activeName == item.key"
            :type="item.key"
            @create="showCreatedTimes"
          />
        </keep-alive>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import TabPane from './TabPane'

export default {
  name: 'Tab',
  components: { TabPane },
  props: {
    createTpye: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      tabMapOptions: [
        { label: 'standardOrder', key: 'standardOrder' },
        { label: 'quickOrder', key: 'quickOrder' }
      ],
      activeName: 'standardOrder'
      // createdTimes: 0
    }
  },
  watch: {
    activeName(val) {
      this.$router.push(`${this.$route.path}?tab=${val}`)
    }
  },
  created() {
    // init the default selected tab
    const tab = this.$route.query.tab
    if (tab) {
      this.activeName = tab
    }
  },
  methods: {
    showCreatedTimes() {
      // this.createdTimes = this.createdTimes + 1
    }
  }
}
</script>

<style lang="scss" scoped>
// .el-tabs--border-card {
//   background: transparent;
//   border: 1px solid #dcdfe6;
//   box-shadow: none;
// }
</style>
<style lang="scss"></style>
